package org.anderground.editor.gui.properties.station;

import org.anderground.core.Logger;
import org.anderground.core.model.Station;
import org.anderground.core.util.Coord;
import org.anderground.editor.edits.EditsManager;
import org.anderground.editor.edits.SetStationPositionAction;

public class StationPositionProperty extends AbstractStringStationProperty {

	@Override
	protected String getValue(Station station) {
		return (station.getPosition() != null) ? station.getPosition()
				.toString() : "(0;0)";
	}

	@Override
	protected void setValue(Station station, String cellEditorValue) {
		Coord newCoord = Coord.parsePosition(cellEditorValue);
		Logger.i(newCoord + "");
		EditsManager.getInstance().performAction(
				new SetStationPositionAction(newCoord, station));
		Logger.i(newCoord + "");
	}

	@Override
	public String getPropertyName() {
		return "Position";
	}

	@Override
	public boolean isEditable() {
		return true;
	}
}
